package com.golxen.framework.common.server.agent.cmd;

import com.golxen.framework.AgentProtocol;
import com.golxen.framework.PBPacket.PBPacket;
import com.golxen.framework.common.server.agent.AgentPlayerMgr;
import com.golxen.framework.common.server.game.cmd.Cmd;
import com.golxen.framework.common.server.game.cmd.Command;
import com.golxen.utils.LogUtil;
import io.netty.channel.ChannelHandlerContext;

@Cmd(code = AgentProtocol.A_KICK_OUT_PLAYER, desc = "踢玩家下线(会向游戏服发清缓存消息)")
public class KickOutPlayerCmd implements Command {

	@Override
	public Command.Tuple execute(ChannelHandlerContext ctx, PBPacket packet) throws Exception {
		long userId = packet.getPlayerId();

		String ip = ctx.channel().remoteAddress().toString();
		LogUtil.COMMON.info("[loginmark] agent kickout {} {} {} {}", ctx.channel().id().asShortText(),
				ctx.channel().remoteAddress(), userId, ip);

		AgentPlayerMgr.kickOutPlayer(userId);

		return new Tuple(null, null);
	}

}
